<html>
<head><meta charset="utf-8"><title>Check if a type(Ty) is an empty tuple · t-compiler/help · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/index.html">t-compiler/help</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Check.20if.20a.20type(Ty).20is.20an.20empty.20tuple.html">Check if a type(Ty) is an empty tuple</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="220401925"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Check%20if%20a%20type%28Ty%29%20is%20an%20empty%20tuple/near/220401925" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> xFrednet <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Check.20if.20a.20type(Ty).20is.20an.20empty.20tuple.html#220401925">(Dec 18 2020 at 17:23)</a>:</h4>
<p>Is there a simple way to check if a <a href="https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/struct.TyS.html"><code>rustc_middle::ty::TyS</code></a> instance  is an empty tuple <code>()</code>? <br>
(I'm working on a lint for clippy so I'm not sure if this is the correct channel <span aria-label="sweat smile" class="emoji emoji-1f605" role="img" title="sweat smile">:sweat_smile:</span> )</p>



<a name="220402158"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Check%20if%20a%20type%28Ty%29%20is%20an%20empty%20tuple/near/220402158" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Check.20if.20a.20type(Ty).20is.20an.20empty.20tuple.html#220402158">(Dec 18 2020 at 17:24)</a>:</h4>
<p>I think you can check if the <code>kind</code> is a <a href="https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/sty/enum.TyKind.html#variant.Tuple"><code>Tuple</code></a> with a length of 0: <a href="https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/list/struct.List.html">https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/list/struct.List.html</a></p>



<a name="220402439"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Check%20if%20a%20type%28Ty%29%20is%20an%20empty%20tuple/near/220402439" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthew Jasper <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Check.20if.20a.20type(Ty).20is.20an.20empty.20tuple.html#220402439">(Dec 18 2020 at 17:26)</a>:</h4>
<p><a href="https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/struct.TyS.html#method.is_unit">https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/struct.TyS.html#method.is_unit</a></p>



<a name="220402665"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Check%20if%20a%20type%28Ty%29%20is%20an%20empty%20tuple/near/220402665" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> xFrednet <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Check.20if.20a.20type(Ty).20is.20an.20empty.20tuple.html#220402665">(Dec 18 2020 at 17:28)</a>:</h4>
<p>Thank you that's what I was looking for! I wasn't sure how it was called that complicated the search for it. <span aria-label="upside down" class="emoji emoji-1f643" role="img" title="upside down">:upside_down:</span></p>



<a name="220420262"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Check%20if%20a%20type%28Ty%29%20is%20an%20empty%20tuple/near/220420262" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Noah Lev <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Check.20if.20a.20type(Ty).20is.20an.20empty.20tuple.html#220420262">(Dec 18 2020 at 19:50)</a>:</h4>
<p>FYI <code>()</code> is called the "unit type"; that's why the function is <code>TyS::is_unit</code> :)</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>